<template>
  <div>
    <el-form style="width: 400px" inline>
      <el-form-item label="订单来源">
        <el-select v-model="order.paymentWay">
          <el-option value="天猫">天猫</el-option>
          <el-option value="淘宝">淘宝</el-option>
          <el-option value="修理厂">修理厂</el-option>
          <el-option value="中保客服">中保客服</el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="车 牌 号">
        <el-input v-model="order.carPlate"></el-input>
      </el-form-item>
      <el-form-item label="预检时间">
        <el-date-picker
          v-model="order.placeTestTime"
          type="datetime"
          placeholder="选择日期时间 "
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="实付价格">
        <el-input v-model="order.carPrice" type="number"></el-input>
      </el-form-item>
      <el-form-item label="客户姓名">
        <el-input v-model="order.customerName"></el-input>
      </el-form-item>
      <el-form-item label="客户电话">
        <el-input v-model="order.customerPhone" type="number"></el-input>
      </el-form-item>
      <el-form-item label="居住地址">
        <pickArea @getSize="getSize"></pickArea>
        <el-input v-model="order.address"></el-input>
      </el-form-item>
      <el-form-item label="行驶证或车辆照片">
        <el-upload  class="upload-demo" drag :action="this.$http.defaults.baseURL+'/file/uploadFile'" multiple :on-success="achengGong">
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
          <div class="el-upload__tip" slot="tip"> 只能上传jpg/png文件，且不超过500kb </div>
        </el-upload>
      </el-form-item>
      <el-form-item label="电子保单（非必填）">
        <el-upload class="upload-demo" drag :action="this.$http.defaults.baseURL+'/file/uploadFile'" multiple :on-success="bchengGong">
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
          <div class="el-upload__tip" slot="tip">只能上传jpg/png文件，且不超过500kb</div>
        </el-upload>
      </el-form-item>
      <el-form-item label="备注">
        <el-input v-model="order.remarks" type="textarea"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="creatOrder">立即创建</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import pickArea from "../../components/pickArea";
export default {
  components: {
    pickArea,
  },
  inject:["reload"],
  data() {
    return {
      order: {
          licenseImgs:[],
          policyImgs:[],
      },
    };
  },
  methods: {
    getSize: function (prov, city, area) {
      this.order.province = prov;
      this.order.city = city;
      this.order.area = area;
    },
    creatOrder: function () {
    //   console.log(this.order);
     this.$http.post("/order/placeCStoreOrder",this.order).then((res)=>{
            //    console.log(res);
            if(res.data.code){
                this.$message.success("录入订单成功");
                this.reload()
            }
     })
    },
    achengGong:function(res){
    //    console.log(res);
        this.order.licenseImgs.push(res.object.url)
    },
    bchengGong:function(res){
        this.order.policyImgs.push(res.object.url)
    }
  },
};
</script>

<style></style>
